﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;

namespace AppDAL
{
  public  class ExcelHelper
    {
      OleDbConnection oleDbConnection = new OleDbConnection();
      public ExcelHelper(string connectionString)
      {
          oleDbConnection.ConnectionString  = connectionString;
      }
      public static DataSet ExecuteData(string connectionString, string commandText)
      {
          try
          {
              OleDbConnection oleDbConnection = new OleDbConnection();
              OleDbCommand oledbCommand = new OleDbCommand();
              oledbCommand.CommandText = commandText;
              oledbCommand.CommandType = CommandType.Text;
              oledbCommand.Connection = oleDbConnection;
              OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
              oleDbConnection.ConnectionString = connectionString;
              dataAdapter.SelectCommand = oledbCommand;
              DataSet ds = new DataSet();
              dataAdapter.Fill(ds);
              return ds;
          }
          catch
          {
              throw;
          }

        
      }
    }
}
